package ifi.card.Funtion;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

public class RegularFuntion {
public RegularFuntion(){
	}
	public void loadResource(Bitmap img, Resources res,int id){
		img=BitmapFactory.decodeResource(res,id);
	}

	public static void drawImg(Canvas canvas,Bitmap bm,int top,int left)
	{
		canvas.drawBitmap(bm,left,top,null);
	}

	public boolean checkInButton(int xTout,int yTout, int xButton,
										int yButton,int widthButton,int heightButton){
		if((xTout>=xButton)&&(yTout>=yButton)&&(xTout<=xButton+widthButton)
				&&(yTout<=yButton+heightButton))
		return true; else return false;
	}

	public void drawPartImg(Canvas canvas,Bitmap bmp,float xDraw,float yDraw,
			int xStart,int yStart,int width,int height){
			Bitmap partOfImg;
			partOfImg=Bitmap.createBitmap(bmp, xStart, yStart, width, height);
			canvas.drawBitmap(partOfImg, xDraw, yDraw, null);
	}

	public void drawRateImg(Canvas canvas, Bitmap bmp,int xDraw,int yDraw,
			 int width, int height){
			Bitmap rateOfImg;
			rateOfImg=Bitmap.createScaledBitmap(bmp,width,height,true);
			canvas.drawBitmap(rateOfImg, xDraw, yDraw, null);
			
	}

	public void drawRateOfPartImg(Canvas canvas, Bitmap bmp, int xDraw,int yDraw,int xStart,int yStart,int width,int height,int widthRate, int heightRate){
			Bitmap partOfImg,rateOfImg;
			partOfImg=Bitmap.createBitmap(bmp, xStart, yStart, width, height);
			rateOfImg=Bitmap.createScaledBitmap(partOfImg,widthRate,heightRate,true);
			canvas.drawBitmap(rateOfImg, xDraw, yDraw, null);
			partOfImg=null; 
			rateOfImg=null;
	}

}
